<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
<#assign base=request.contextPath  />
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title></title>
    <link rel="stylesheet" href="${base}/frame/layui/css/layui.css">
    <link rel="stylesheet" href="${base}/frame/static/css/style.css">
    <link rel="icon" href="${base}/frame/static/image/code.png">
    <script type="text/javascript" src="${base}/js/zhang.js"></script>
    <script   src="${base}/jquery-1.8.3.min.js"></script>
    <style type="text/css">
        html { overflow-x: hidden; overflow-y: auto; }
        .layui-table-fixed-r td{height:58px!important;}
        .layui-table-fixed-r th{height:58px!important;}
        .layui-table img {
            max-width: 48px;min-height: 48px;
        }


        .laytable-cell-3-wx_headimg ,.laytable-cell-1-wx_headimg,.laytable-cell-2-wx_headimg,.laytable-cell-3-wx_headimg,.laytable-cell-4-wx_headimg,.laytable-cell-5-wx_headimg,.laytable-cell-6-wx_headimg,.laytable-cell-7-wx_headimg,.laytable-cell-8-wx_headimg,.laytable-cell-9-wx_headimg,.laytable-cell-10-wx_headimg,.laytable-cell-11-wx_headimg,.laytable-cell-12-wx_headimg,.laytable-cell-13-wx_headimg,.laytable-cell-14-wx_headimg{
            width: 48px!important;;padding:0px!important;height: 48px!important;;
            line-height: 48px!important;;
        }
        .layui-form-item{
            border-bottom: 2px solid #F2F2F2;
        }
        .layui-input-block{
            min-height: 53px;
        }
        img{
            width:110px;height:70px;line-height: 70px;
        }
    </style>
</head>
<body class="body">
<form class="layui-form"  id="form">
    <div class="layui-form-item">
        <label class="layui-form-label"><a style="color:red">*</a>&nbsp;车名</label>
        <div class="layui-input-block">
            <input name="carName" id="carName" lay-verify=""  placeholder="请输入车名" autocomplete="off" class="layui-input isNull" type="text">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"><a style="color:red">*</a>&nbsp;车型号</label>
        <div class="layui-input-block">
            <input id="carModel" lay-verify="" placeholder="车型号" autocomplete="off" class="layui-input isNull" type="text">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"><a style="color:red">*</a>&nbsp;车品牌</label>
        <div class="layui-input-block">
            <input id="carBrand" lay-verify=""  placeholder="车品牌" autocomplete="off" class="layui-input isNull " type="text">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"><a style="color:red">*</a>&nbsp;续航</label>
        <div class="layui-input-block">
            <input id="carRenewal" lay-verify=""  placeholder="续航" autocomplete="off" class="layui-input isNull " type="text">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"><a style="color:red">*</a>&nbsp;有无保险</label>
        <div class="layui-input-inline">
            <select id="carInsurance">
                <option value="有无保险">有无保险</option>
                <option value="有">有</option>
                <option value="无">无</option>
            </select>
        </div>
    </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><a style="color:red">*</a>&nbsp;车辆余额</label>
            <div class="layui-input-block">
                <input id="moeny" lay-verify=""  placeholder="车辆余额" autocomplete="off" class="layui-input isNull " type="text">
            </div>
        </div>

    <div class="layui-form-item">
        <label class="layui-form-label"><a style="color:red">*</a>&nbsp;车牌</label>
        <div class="layui-input-block">
            <input id="carPlate" lay-verify=""  placeholder="车牌" autocomplete="off" class="layui-input isNull " type="text">
        </div>
    </div>
    <#--<div class="layui-form-item">-->
        <#--<label class="layui-form-label"><a style="color:red">*</a>&nbsp;车辆名</label>-->
        <#--<div class="layui-input-block">-->
            <#--<input id="vehicleName" lay-verify=""  placeholder="请输入车辆名" autocomplete="off" class="layui-input isNull " type="text">-->
        <#--</div>-->
    <#--</div>-->
    <#--<div class="layui-form-item">-->
        <#--<label class="layui-form-label"><a style="color:red">*</a>&nbsp;载重</label>-->
        <#--<div class="layui-input-block">-->
            <#--<input id="carload" lay-verify=""  placeholder="请输入载重" autocomplete="off" class="layui-input isNull " type="text">-->
        <#--</div>-->
    <#--</div>-->
    <#--<div class="layui-form-item">-->
        <#--<label class="layui-form-label"><a style="color:red">*</a>&nbsp;续航</label>-->
        <#--<div class="layui-input-block">-->
            <#--<input id="renewal" lay-verify=""  placeholder="请输入续航" autocomplete="off" class="layui-input isNull " type="text">-->
        <#--</div>-->
    <#--</div>-->
    <#--<div class="layui-form-item">-->
        <#--<label class="layui-form-label"><a style="color:red">*</a>&nbsp;轴距</label>-->
        <#--<div class="layui-input-block">-->
            <#--<input id="wheelbase" lay-verify=""  placeholder="请输入轴距" autocomplete="off" class="layui-input isNull " type="text">-->
        <#--</div>-->
        <#--<div class="layui-form-item">-->
            <#--<label class="layui-form-label"><a style="color:red">*</a>&nbsp;有无保险</label>-->
            <#--<div class="layui-input-block">-->
                <#--<select name="interest" lay-filter="" id="insurance">-->
                    <#--<option value="2">无</option>-->
                    <#--<option value="1" selected="">有</option>-->
                <#--</select>-->
            <#--</div>-->
        <#--</div>-->
    <#--</div>-->
    <#--<div class="layui-form-item">-->
        <#--<label class="layui-form-label"style="height: 70px;" >车辆轮播图<button type="button" class="layui-btn layui-btn-xs layui-btn-normal" id="test2">上传图片</button></label>-->
        <#--<div class="layui-upload"><span id="demo2"></span></div>-->
    <#--</div>-->
    <#--<div class="layui-form-item">-->
        <#--<label class="layui-form-label"style="height: 70px;" >车辆首页展示图<button type="button" class="layui-btn layui-btn-xs layui-btn-normal" id="test1">上传图片</button></label>-->
        <#--<img class="layui-upload-img" id="demo1">-->
    <#--</div>-->
<#--   <div class="layui-form-item">
       <label class="layui-form-label"style="height: 70px;" >行车证<button type="button" class="layui-btn layui-btn-xs layui-btn-normal" id="test3">上传图片</button></label>
       <div class="layui-upload"><span id="demo3"></span></div>
   </div>-->
    <div  style="float: right;margin-bottom: 50px ; margin-right: 20px;">
        <div class="layui-input-block">
            <button type="reset" class="layui-btn layui-btn-primary">取消</button>
            <button class="layui-btn layui-btn-normal" id="test9" type="button" onclick="sub()" >确定</button>
        </div>
    </div>
</form>
<script type="text/javascript" src="${base}/frame/layui/layui.js"></script>
<script type="text/javascript" src="${base}/js/index.js"></script>
<script>


    //查询字典表状态
    var bas='${base}';
    var homeState=   getDataByCode(bas,"carType");
    for(var i=0;i<homeState.length;i++){
        $("#carType").append(
                '<option value="'+homeState[i].id+'">'+homeState[i].name+'</option>'
        )
    }


    <#--//预计上传的所有文件ID-->
    <#--var fileIds=[];-->
    layui.use(['form','upload'], function(){

        var $ = layui.jquery
                ,form = layui.form
                ,upload = layui.upload;

        <#--&lt;#&ndash;//普通图片上传&ndash;&gt;-->
        <#--&lt;#&ndash;var uploadInst = upload.render({&ndash;&gt;-->
            <#--&lt;#&ndash;elem: '#test1'&ndash;&gt;-->
            <#--&lt;#&ndash;,url: '${base}/car/upload'&ndash;&gt;-->
            <#--&lt;#&ndash;,before: function(obj){&ndash;&gt;-->
                <#--&lt;#&ndash;layer.load(); //上传loading&ndash;&gt;-->
                <#--&lt;#&ndash;//预读本地文件示例，不支持ie8&ndash;&gt;-->
                <#--&lt;#&ndash;obj.preview(function(index, file, result){&ndash;&gt;-->
                    <#--&lt;#&ndash;$('#demo1').attr('src', result); //图片链接（base64）&ndash;&gt;-->
                <#--&lt;#&ndash;});&ndash;&gt;-->
            <#--&lt;#&ndash;}&ndash;&gt;-->
            <#--&lt;#&ndash;,auto:true&ndash;&gt;-->
            <#--&lt;#&ndash;,data: {&ndash;&gt;-->
                <#--&lt;#&ndash;isCarIndex:1&ndash;&gt;-->
            <#--&lt;#&ndash;}&ndash;&gt;-->
            <#--&lt;#&ndash;,done: function(res){&ndash;&gt;-->
                <#--&lt;#&ndash;layer.closeAll('loading'); //关闭loading&ndash;&gt;-->
                <#--&lt;#&ndash;layer.msg(res.msg)&ndash;&gt;-->
                <#--&lt;#&ndash;fileIds.push(res.data.fileId);&ndash;&gt;-->
            <#--&lt;#&ndash;}&ndash;&gt;-->
        <#--&lt;#&ndash;});&ndash;&gt;-->

        <#--&lt;#&ndash;//多图片上传&ndash;&gt;-->
        <#--&lt;#&ndash;upload.render({&ndash;&gt;-->
            <#--&lt;#&ndash;elem: '#test2'&ndash;&gt;-->
            <#--&lt;#&ndash;,url: '${base}/car/upload'&ndash;&gt;-->
            <#--&lt;#&ndash;,multiple: true&ndash;&gt;-->
            <#--&lt;#&ndash;,&ndash;&gt;-->
            <#--&lt;#&ndash;before:function (obj){&ndash;&gt;-->
                <#--&lt;#&ndash;layer.load(); //上传loading&ndash;&gt;-->
                <#--&lt;#&ndash;//预读本地文件示例，不支持ie8&ndash;&gt;-->
                <#--&lt;#&ndash;obj.preview(function(index, file, result){&ndash;&gt;-->
                    <#--&lt;#&ndash;$('#demo2').append('<img src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img">')&ndash;&gt;-->
                <#--&lt;#&ndash;});&ndash;&gt;-->
            <#--&lt;#&ndash;}&ndash;&gt;-->
            <#--&lt;#&ndash;,auto:true&ndash;&gt;-->
            <#--&lt;#&ndash;,data: {&ndash;&gt;-->
                <#--&lt;#&ndash;isCarIndex:2&ndash;&gt;-->
            <#--&lt;#&ndash;}&ndash;&gt;-->
            <#--&lt;#&ndash;//上传完毕回调函数&ndash;&gt;-->
            <#--&lt;#&ndash;,done: function(res){&ndash;&gt;-->
                <#--&lt;#&ndash;layer.closeAll('loading'); //关闭loading&ndash;&gt;-->
                <#--&lt;#&ndash;layer.msg(res.msg)&ndash;&gt;-->
                <#--&lt;#&ndash;fileIds.push(res.data.fileId);&ndash;&gt;-->
            <#--&lt;#&ndash;}&ndash;&gt;-->
        <#--&lt;#&ndash;});&ndash;&gt;-->



    });

    function sub(){
        if(!isNull()){
            return;
        }
        if (!isNum()) {
            return;
        }
        if (!isPhone()) {
            return;
        }
        var formData={};
        formData.carName=$("#carName").val();
        formData.carModel=$("#carModel").val();
        formData.carBrand=$("#carBrand").val();
        formData.carRenewal=$("#carRenewal").val();
        formData.moeny=$("#moeny").val();
        formData.carPlate=$("#carPlate").val();
        formData.carInsurance=$("#carInsurance").val();

        $.ajax({
            type: "post",
            traditional: true,//这里设置为true,不然后台接收到的参数会带上[]，导致数据无法正常接收
            data: {param:JSON.stringify(formData)},
            url: "${base}/car/insert",
            success: function (data) {
                data=JSON.parse(data);
                if (data.equals("添加成功")){
                    window.location.href="${base}/car/main.html"
                }else{
                    layer.msg(data.msg)
                }
            }
        });



        var formData1={};
        formData1.vehicleName=$("#vehicleName").val();
        formData1.carload=$("#carload").val();
        formData1.renewal=$("#renewal").val();
        formData1.wheelbase=$("#wheelbase").val();
        formData1.insurance=$("#insurance").val();
        /**
         * insertb:把vehicleName，carload，renewal，wheelbase，insurance添加到表we_carsource中
         */
        $.ajax({
            type: "post",
            traditional: true,//这里设置为true,不然后台接收到的参数会带上[]，导致数据无法正常接收
            data: {param:JSON.stringify(formData1)},
            url: "${base}/weCarsource/insert",
            success: function (data) {
                if (data){
                    window.location.href="${base}/car/main.html"
                }else{
                    alert("xxx");
                }

            }
        });
    }

</script>
</body>
</html>